#include "EquationSolver.h"
#include <limits>

double pi = acos(-1);
double eps = numeric_limits<double>::epsilon();

class Func : public Function{
public:
  double operator()(double x){
    return 10*(0.5*pi-asin(x)-x*sqrt(1-x*x))-12.4;
  }
  double diff(double x){
    return -20*sqrt(1-x*x);
  }
};

Func f;

double test1(){
  Bisection solver(f, 0, 1, eps, eps, 100);
  double result = solver.solve();
  result = 1-result; 
  return result;
}

double test2(){
  Newton solver(f, 0, eps, 10);
  double result = solver.solve();
  result = 1-result; 
  return result;
}

double test3(){
  Secant solver(f, 0, 1, eps, eps, 100);
  double result = solver.solve();
  result = 1-result; 
  return result;
}

int main(){
  cout << "(Bisection Method) The depth of water is " << test1() << endl;
  cout << "(Newton  Method) The depth of water is " << test2() << endl;
  cout << "(Secant Method) The depth of water is " << test3() << endl;
  return 0;
}
